package com.lzxuni.modules.pccontrol.basics.real.controller;

import com.alibaba.fastjson.JSON;
import com.lzxuni.common.annotation.SysLog;
import com.lzxuni.common.constant.LogConstant;
import com.lzxuni.common.utils.R;
import com.lzxuni.common.utils.StringUtils;
import com.lzxuni.modules.common.controller.BaseController;
import com.lzxuni.modules.common.entity.PageData;
import com.lzxuni.modules.common.entity.PageParameter;
import com.lzxuni.modules.pccontrol.basics.real.entity.RealCar;
import com.lzxuni.modules.pccontrol.basics.real.service.RealCarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

/**
 * 基础管理_实名认证 前端控制器
 * Created by 潘云明
 * 2019/7/10
 */

@RestController
@RequestMapping("/pccontrol/basics/realcar")
public class RealCarController extends BaseController {
    @Autowired
    private RealCarService service;

    @RequestMapping("/Index")
    @SysLog(categoryId = 2, module = "查看车辆认证", operateType = "访问")
    public ModelAndView list() {
        ModelAndView mv = new ModelAndView("/pccontrol/basics/real/realcar_index");
        return mv;
    }

    @RequestMapping("/GetList")
    public Object GetList(String pagination) {
        RealCar entity=new RealCar();
        entity.setIspass("0");
        //1.Json转换成实体类
        PageParameter pageParameter = JSON.parseObject(pagination, PageParameter.class);
        //调用父类的一个方法，传进一个参数pageParameter进行查询操作将在业务层将结果直接封装进PageInfo中然后将PageInfo数据封装进pageData中，返回到页面中
        PageData pageData = getPageData(service.queryPage(pageParameter, entity));
        return R.ok().put("data", pageData);
    }


    @RequestMapping("/Form")
    public ModelAndView Form() {
        ModelAndView mv = new ModelAndView("/pccontrol/basics/real/realcar_form");
        return mv;
    }


    @SysLog(categoryId = LogConstant.OPERATEID, module = "查看地址管理_省", operateType = LogConstant.INSERT)
    @RequestMapping("/SaveForm")
    public Object SaveForm(String keyValue, String ispass) {
        if (StringUtils.isNotEmpty(keyValue)) {
            RealCar realCar = new RealCar();
            realCar.setId(keyValue);
            realCar.setIspass(ispass);
            service.updateById(realCar);
            return R.ok("修改成功");
        }
        return R.ok("修改成功");
    }


}
